import java.util.*;
class Solution {
    public List<Long> maximumEvenSplit(long finalSum) {
        List<Long> ans = new LinkedList();
        if(finalSum%2 != 0) return ans;
        for(int i=2; i<=finalSum; i+=2){
            ans.add((long)i);
            finalSum -= i;
        }
        ans.set(ans.size()-1,ans.get(ans.size()-1)+finalSum);
        return ans;
    }
}
class Solution {
    public static long continuousSubarrays(int[] nums) {
        int[] a = new int[nums.length];
        int[] b = new int[nums.length];
        int head = 0, headB = 0;
        int last = 0, lastB = 0;
        int j = 0;
        long ans = 0;
        for(int i=0; i<nums.length; i++){
            while(head < last && nums[a[last-1]]<nums[i]){
                last--;
            }
            while(headB < lastB && nums[b[lastB-1]]>nums[i]){
                lastB--;
            }
            a[last++] = i;
            b[lastB++] = i;
            while(head < last && headB < lastB && nums[a[head]]-nums[b[headB]] > 2){
                if(a[head]<b[headB]){
                    head++;
                }else{
                    headB++;
                }
                j = a[head] > b[headB] ? b[headB] : a[head];
            }
            ans += i - j + 1;
        }
        return ans;
    }
}

/*
//
class Solution1 {
    public ListNode deleteDuplicates(ListNode head) {
        ListNode nh = new ListNode();
        nh.next = head;
        ListNode cur = nh;
        while(cur.next != null &&  cur.next.next != null){
            int val = cur.next.val;
            if( val == cur.next.next.val){
                while(cur.next != null && cur.next.val == val){
                    cur.next = cur.next.next;
                }
            }else{
                cur = cur.next;
            }
        }
        return nh.next;
    }
}
//237
class Solution2 {
    public void deleteNode(ListNode node) {
        node.val = node.next.val;
        node.next = node.next.next;
    }
}
public class Testt {
    public static void main(String[] args) {
        Queue<Integer> a = new LinkedList<>();
        a.isEmpty()
    }
}
*/
